//
//  XJ_ManageCreditCardViewController.m
//  XunJieProject
//
//  Created by xue on 2018/6/12.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "XJ_ManageCreditCardViewController.h"
#import "XJ_AlextShowView.h"
#import "BC_KeFuAlextView.h"

@interface XJ_ManageCreditCardViewController ()
@property (weak, nonatomic) IBOutlet UIButton *deleteBtn;
@property (weak, nonatomic) IBOutlet UITextField *cardIdTF;
@property (weak, nonatomic) IBOutlet UITextField *billDatTF;
@property (weak, nonatomic) IBOutlet UITextField *repayTimeTF;
@property (weak, nonatomic) IBOutlet UITextField *CNV2TF;
@property (weak, nonatomic) IBOutlet UITextField *validityDateTF;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewTop;


@end

@implementation XJ_ManageCreditCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _scrollViewTop.constant = SafeAreaTopHeight;
    // Do any additional setup after loading the view from its nib.
}

-(void)creatMainUI{
    
    self.nav_titleLabel.text =@"管理信用卡";
    
    _deleteBtn.layer.cornerRadius =2;
    _deleteBtn.layer.borderColor =Color_Line.CGColor;
    _deleteBtn.layer.borderWidth=1;
    [_deleteBtn setTitleColor:Color_ZhuSeDiao forState:UIControlStateNormal];
    
    _cardIdTF.text = _cardModel.cardId;
    _billDatTF.text = _cardModel.billDate;
    _repayTimeTF.text = _cardModel.backMoneyDate;
    _CNV2TF.text = _cardModel.cvn2;
    _validityDateTF.text = _cardModel.periodDate;
    
}
- (IBAction)Click_btn:(id)sender {
//    [self.view endEditing:YES];
//    __weak typeof(self) weakSelf = self;
    UIButton *button =(UIButton*)sender;
    switch (button.tag) {
        
//        case 0://账单日
//        {
//
//            [BRStringPickerView showStringPickerWithTitle:nil dataSource:self.daysArr defaultSelValue:self.daysArr[4] isAutoSelect:NO resultBlock:^(id selectValue) {
//                weakSelf.billDatTF.text =selectValue;
//            }];
//
//        }
//            break;
//        case 1://还款日
//        {
//
//
//            [BRStringPickerView showStringPickerWithTitle:nil dataSource:self.daysArr defaultSelValue:self.daysArr[4] isAutoSelect:NO resultBlock:^(id selectValue) {
//                weakSelf.repayTimeTF.text = selectValue;
//
//            }];
//        }
//            break;
//        case 2://CNV2
//        {
//            XJ_AlextShowView *alext =[[XJ_AlextShowView alloc]initWithImage:@"cvn2_img"];
//            [alext showXLAlertView];
//        }
//            break;
//        case 3://有效期
//        {
//            XJ_AlextShowView *alext =[[XJ_AlextShowView alloc]initWithImage:@"validity_img"];
//            [alext showXLAlertView];
//        }
//            break;
        
        case 4://删除
        {
            BC_KeFuAlextView *alext =[[BC_KeFuAlextView alloc]initWithMessage:@"提示" sureBtn:@"确定" cancleBtn:@"取消" phone:@"确定删除吗？" delete:YES];
            alext.resultIndex = ^(NSInteger index) {
               
                [self delegateCardAction];
            };
            [alext showXLAlertView];
            
            
//            if (_cardIdTF.text.length==0) {
//                ZDXAlertView *alext =[[ZDXAlertView alloc]initWithMessage:@"信用卡号为空" image:@"pop_msg_tip_xs"];
//                [alext showXLAlertView];
//                return;
//            }
//
//            if (_billDatTF.text.length==0) {
//                ZDXAlertView *alext =[[ZDXAlertView alloc]initWithMessage:@"账单日为空" image:@"pop_msg_tip_xs"];
//                [alext showXLAlertView];
//                return;
//            }
//
//            if (_repayTimeTF.text.length==0) {
//                ZDXAlertView *alext =[[ZDXAlertView alloc]initWithMessage:@"还款日为空" image:@"pop_msg_tip_xs"];
//                [alext showXLAlertView];
//                return;
//            }
//
//            if (_CNV2TF.text.length==0) {
//                ZDXAlertView *alext =[[ZDXAlertView alloc]initWithMessage:@"CVN2为空" image:@"pop_msg_tip_xs"];
//                [alext showXLAlertView];
//                return;
//            }
//
//            if (_validityDateTF.text.length==0) {
//                ZDXAlertView *alext =[[ZDXAlertView alloc]initWithMessage:@"有效期为空" image:@"pop_msg_tip_xs"];
//                [alext showXLAlertView];
//                return;
//            }
            
            
            
           
        }
            break;
            
        default:
            break;
    }
}

- (void)delegateCardAction{
    
    NSUserDefaults * db = [NSUserDefaults standardUserDefaults];
    NSString * token = [db objectForKey:@"token"];
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    [dic setValue:IDENTIFIER forKey:@"equipmentNo"];
    [dic setValue:APPVERSION forKey:@"appVersion"];
    [dic setValue:STSTERMVERSION forKey:@"systemVersion"];
    [dic setValue:USERID forKey:@"userId"];
    
    if (token!=nil &&![token isEqualToString:@""]) {
        
        [dic setValue:token forKey:@"token"];
        
    }
     [dic setValue:_cardModel.cardId forKey:@"cardId"];
    
    [XJ_Utils signPost:@"card/unbundle?" parameters:dic success:^(NSInteger recode, id jsonObject) {
        ZDXAlertView *alext =[[ZDXAlertView alloc]initWithMessage:@"成功" image:@"pop_msg_succeed_xs"];
        [alext showXLAlertView];
        [self.navigationController popToRootViewControllerAnimated:YES];
      
    } failure:^(NSInteger recode, NSError *error) {
        
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
